package practise.hibernate.persistence;

import practise.hibernate.interceptor.LogInterceptor;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Entity(name = "address")
@Table(name = "ADDRESS")
@EntityListeners(LogInterceptor.class)
public class Address {
    @Id
    @Column(name = "id")
    private int id;
    @Column(name = "location")
    private String location;
    @Column(name = "street")
    private String street;
    @OneToMany(mappedBy = "address" , cascade = {CascadeType.PERSIST , CascadeType.MERGE })
    private List<Person> persons;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public List<Person> getPersons() {
        return persons;
    }

    public void setPersons(List<Person> persons) {
        this.persons = persons;
    }
}
